Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master-2.x] Force sync state root from all peers #1854

Merged
merged 6 commits into from
Sep 1, 2020

Conversation

ZhangTao1596
Copy link
Contributor

Fix root sync slowly in mast-2.x, especially many peers are 2.10.3.

  • Treat state root sync task as global task
  • Ask all connected peers when get state roots

Risk: peers will do repeated work and node will receive some redundant messages from different peers.

@ZhangTao1596
Copy link
Contributor Author

@erikzhang @shargon Can you review this?

@@ -281,15 +286,11 @@ private void RequestTasks(TaskSession session)
var height = Blockchain.Singleton.Height;
if (state_height + 1 < height)
{
var state = Blockchain.Singleton.GetStateRoot((uint)(state_height + 1));
if (state is null || state.Flag == StateRootVerifyFlag.Unverified)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After every block persisted, local state root will be calculated and persist into StateRoots with Unverified flag. Only check the block height is enough.

PersistLocalStateRoot();

shargon
shargon previously approved these changes Aug 25, 2020
@superboyiii
Copy link
Member

superboyiii commented Sep 1, 2020

I've already applied it on testnet seeds and all works well for more than a week. Root never stops sync again.

@erikzhang erikzhang merged commit a423b18 into neo-project:master-2.x Sep 1, 2020
@ZhangTao1596 ZhangTao1596 deleted the fix-2.x-root-sync branch September 2, 2020 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants